﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ALiteTeam.PackageTracer.Core
{
    public static class ThemeEx
    {
        /// <summary>
        /// 判断当前主题的背景色是否为黑色
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public static bool IsBlackBackgroup(this Application app)
        {
            Visibility v = (Visibility)app.Resources["PhoneDarkThemeVisibility"];
            if (v == System.Windows.Visibility.Visible)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 获取当前背景色名
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public static string GetCurrentBackgroupName(this Application app)
        {
            if (app.IsBlackBackgroup() == true)
            {
                return "dark";
            }
            else
            {
                return "light";
            }
        }

        public static Uri GetIconUri(this Application app, AppBarIcons icon)
        {
            Uri result; 

            var iconName = string.Format(@"appbar.{0}.rest.png", icon);
            var subFolderName = app.GetCurrentBackgroupName();
            string uriString = string.Format(@"/Icons/{0}/{1}", subFolderName, iconName);

            result = new Uri(uriString, UriKind.Relative);
            return result;
        }        
    }

    public enum AppBarIcons
    {
        Refresh,
        Settings,
        Search,
        Delete,
        Call,
        Email,
        Message,
        Photo,
        Help,
        About,
        IE
    }

    public enum ThemeColors
    {
        默认,
        明亮,
        彩色
    }
}
